package com.huilang;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public interface Sell {
    Integer sellId(Integer id);
}

class MuBiaoSell implements Sell {
    @Override
    public Integer sellId(Integer id) {
        return id;
    }
}

class ProxyFactory {
    private  MuBiaoSell muBiaoSell=new MuBiaoSell();

    public Sell getSell() {

        Sell sell=(Sell) Proxy.newProxyInstance(
                muBiaoSell.getClass().getClassLoader(),
                muBiaoSell.getClass().getInterfaces(),
                new InvocationHandler() {
                    @Override
                    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                        System.out.println("jdk===");
                        Object invoke = method.invoke(muBiaoSell, args);
                        return invoke;
                    }
                }
        );
        return sell;
    }
}

class SellTest{
    public static void main(String[] args) {
        ProxyFactory factory = new ProxyFactory();
        Sell proxy = factory.getSell();
        Integer i = proxy.sellId(2);
        System.out.println(i);

        System.out.println(proxy.getClass());
        while (true) {

        }
    }
}